package com.seelyn.dowork.repositories;

import com.seelyn.dowork.entities.Tag;
import com.seelyn.dowork.entities.TagExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

public interface TagMapper {
    @SelectProvider(type=TagSqlProvider.class, method="countByExample")
    long countByExample(TagExample example);

    @DeleteProvider(type=TagSqlProvider.class, method="deleteByExample")
    int deleteByExample(TagExample example);

    @Delete({
        "delete from st_tag",
        "where tag_id = #{tagId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long tagId);

    @Insert({
        "insert into st_tag (tag_id, description, ",
        "name)",
        "values (#{tagId,jdbcType=BIGINT}, #{description,jdbcType=VARCHAR}, ",
        "#{name,jdbcType=VARCHAR})"
    })
    int insert(Tag record);

    @InsertProvider(type=TagSqlProvider.class, method="insertSelective")
    int insertSelective(Tag record);

    @SelectProvider(type=TagSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="tag_id", property="tagId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR)
    })
    List<Tag> selectByExampleWithRowbounds(TagExample example, RowBounds rowBounds);

    @SelectProvider(type=TagSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="tag_id", property="tagId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR)
    })
    List<Tag> selectByExample(TagExample example);

    @Select({
        "select",
        "tag_id, description, name",
        "from st_tag",
        "where tag_id = #{tagId,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="tag_id", property="tagId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR)
    })
    Tag selectByPrimaryKey(Long tagId);

    @UpdateProvider(type=TagSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Tag record, @Param("example") TagExample example);

    @UpdateProvider(type=TagSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Tag record, @Param("example") TagExample example);

    @UpdateProvider(type=TagSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Tag record);

    @Update({
        "update st_tag",
        "set description = #{description,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR}",
        "where tag_id = #{tagId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Tag record);
}